﻿var path = "/monitor/user/online";
layui.use(['table', 'laypage'], function () {
    table = layui.table;
    layPage = layui.laypage;
    // 搜索
    $.searchTable.searchBtn();
    /* 初始化表格 */
    initTable();

    //监听行工具事件
    table.on('tool(baseUserOnlineLay)', function (obj) {
        let data = obj.data;
        if ('del' === obj.event) {
            let url = path + '/force/' + data.id;
            $.http.removeMsg(url, '确定退出【' + data.createUser + '】的登录吗？');
        }
    });

});


/* 加载表格 */
function initTable() {
    let name = $("#name").val();
    $.table.init({
        url: path + "/page",
        where: {
            createUser: name
        },
        cols: [[
            {field: 'sessionId', title: '用户会话', align: "center"},
            {field: 'loginName', title: '登录账号', width: 130, align: "center"},
            {field: 'createUser', title: '姓名', width: 130, align: "center"},
            {field: 'clientId', title: '客户端', width: 150, align: "center"},
            {field: 'ipaddr', title: 'IP地址', width: 170, align: "center"},
            {field: 'loginLocation', title: '登录地点', width: 170, align: "center"},
            {field: 'browser', title: '浏览器', width: 130, align: "center"},
            {field: 'os', title: '操作系统', width: 170, align: "center"},
            {field: 'createTime', title: '登录时间', width: 170, align: "center"},
            {fixed: 'right', title: '操作', toolbar: '#toolbarHandle', width: 120, align: "center"}
        ]],
    });
}
